home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.1 KB | 197 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRegion.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
- //
- // This file contains a set of cross-platform functions to manipulate platform regions
- //
-
- #ifndef FWREGION_H
- #define FWREGION_H
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CWritableStream;
- class FW_CLASS_ATTR FW_CReadableStream;
-
- //========================================================================================
- // Platform Region functions
- //========================================================================================
-
- // ----- Region Creation -----
- FW_FUNC_ATTR ODRgnHandle FW_NewRegion();
-
- FW_FUNC_ATTR ODRgnHandle FW_CreateRectRegion(const FW_CRect& rect);
- FW_FUNC_ATTR ODRgnHandle FW_CreateOvalRegion(const FW_CRect& oval);
- FW_FUNC_ATTR ODRgnHandle FW_CreateRoundRectRegion(const FW_CRect& oval, const FW_CPoint& ovalSize);
- FW_FUNC_ATTR ODRgnHandle FW_CreateArcRegion(const FW_CRect& rect, short startAngle, short arcAngle);
- FW_FUNC_ATTR ODRgnHandle FW_CreatePolygonRegion(unsigned long pointCount, const FW_CPoint* pointArray);
- FW_FUNC_ATTR ODRgnHandle FW_CreateLineRegion(const FW_CPoint& startPt, const FW_CPoint& endPt, const FW_CPoint& lineThickness);
-
- // ----- Copy -----
- FW_FUNC_ATTR ODRgnHandle FW_CopyRegion(ODRgnHandle srcRgn);
- FW_FUNC_ATTR void FW_CopyRegion(ODRgnHandle srcRgn, ODRgnHandle dstRgn);
-
- // ----- Dispose -----
- FW_FUNC_ATTR void FW_DisposeRegion(ODRgnHandle rgnHandle);
-
- // ----- Read/Write -----
- FW_FUNC_ATTR void FW_WriteRegion(ODRgnHandle rgnHandle, FW_CWritableStream& stream);
- FW_FUNC_ATTR ODRgnHandle FW_ReadRegion(FW_CReadableStream& stream);
-
- // ----- Equality -----
- FW_FUNC_ATTR FW_Boolean FW_IsEqualRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
-
- // ----- Bounding Box -----
- FW_FUNC_ATTR void FW_GetRegionBoundingBox(ODRgnHandle rgn, FW_CRect& rect);
-
- // ----- Tests -----
- FW_FUNC_ATTR FW_Boolean FW_IsEmptyRegion(ODRgnHandle rgn);
- FW_FUNC_ATTR FW_Boolean FW_PointInRegion(ODRgnHandle rgn, const FW_CPoint& point);
- FW_FUNC_ATTR FW_Boolean FW_RectInRegion(ODRgnHandle rgn, const FW_CRect& rect);
-
- // ----- Region Operations -----
- FW_FUNC_ATTR ODRgnHandle FW_UnionRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
- FW_FUNC_ATTR ODRgnHandle FW_XorRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
- FW_FUNC_ATTR ODRgnHandle FW_SubtractRegion(ODRgnHandle rgn1, ODRgnHandle rgn2); // rgn1 - rgn2
- FW_FUNC_ATTR ODRgnHandle FW_IntersectRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
-
- FW_FUNC_ATTR void FW_UnionRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);
- FW_FUNC_ATTR void FW_XorRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn); // rgn1 - rgn2
- FW_FUNC_ATTR void FW_SubtractRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);
- FW_FUNC_ATTR void FW_IntersectRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);
-
- FW_FUNC_ATTR void FW_OutlineRegion(ODRgnHandle rgn, FW_CFixed outlineSize);
-
- FW_FUNC_ATTR void FW_EmptyRegion(ODRgnHandle rgn);
- FW_FUNC_ATTR void FW_InsetRegion(ODRgnHandle rgn, FW_CFixed x, FW_CFixed y);
- FW_FUNC_ATTR void FW_MapRegion(ODRgnHandle rgn, const FW_CRect& srcRect, const FW_CRect& dstRect);
- FW_FUNC_ATTR void FW_OffsetRegion(ODRgnHandle rgn, FW_CFixed x, FW_CFixed y);
-
- #ifdef FW_BUILD_MAC
- GrafPtr FW_PrivMacOpenRegion();
- ODRgnHandle FW_PrivMacCloseRegion(GrafPtr svPort);
- #endif
-
- //========================================================================================
- // inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_IsEqualRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR FW_Boolean FW_IsEqualRegion(ODRgnHandle rgn1, ODRgnHandle rgn2)
- {
- return ::EqualRgn(rgn1, rgn2);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_IsEmptyRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR FW_Boolean FW_IsEmptyRegion(ODRgnHandle rgn)
- {
- #ifdef FW_BUILD_MAC
- return ::EmptyRgn(rgn);
- #endif
- #ifdef FW_BUILD_WIN
- return ::CombineRgn(rgn, rgn, rgn, RGN_AND) == NULLREGION;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_UnionRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR void FW_UnionRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
- {
- #ifdef FW_BUILD_MAC
- ::UnionRgn(rgn1, rgn2, dstRgn);
- #endif
- #ifdef FW_BUILD_WIN
- ::CombineRgn(dstRgn, rgn1, rgn2, RGN_OR);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_XorRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR void FW_XorRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
- {
- #ifdef FW_BUILD_MAC
- ::XorRgn(rgn1, rgn2, dstRgn);
- #endif
- #ifdef FW_BUILD_WIN
- ::CombineRgn(dstRgn, rgn1, rgn2, RGN_XOR);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_SubtractRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR void FW_SubtractRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
- {
- #ifdef FW_BUILD_MAC
- ::DiffRgn(rgn1, rgn2, dstRgn);
- #endif
- #ifdef FW_BUILD_WIN
- ::CombineRgn(dstRgn, rgn1, rgn2, RGN_DIFF);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_IntersectRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR void FW_IntersectRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
- {
- #ifdef FW_BUILD_MAC
- ::SectRgn(rgn1, rgn2, dstRgn);
- #endif
- #ifdef FW_BUILD_WIN
- ::CombineRgn(dstRgn, rgn1, rgn2, RGN_AND);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_EmptyRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR void FW_EmptyRegion(ODRgnHandle rgn)
- {
- #ifdef FW_BUILD_MAC
- ::SetEmptyRgn(rgn);
- #endif
- #ifdef FW_BUILD_WIN
- ::SetRectRgn(rgn, 0, 0, 0, 0);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_OffsetRegion
- //----------------------------------------------------------------------------------------
- inline FW_FUNC_ATTR void FW_OffsetRegion(ODRgnHandle rgn, FW_CFixed x, FW_CFixed y)
- {
- ::OffsetRgn(rgn, x.AsInt(), y.AsInt());
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-